package cn.wolfcode.plus.mapper;

import cn.wolfcode.plus.domain.Announcement;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.annotations.Param;

/**
 * Author wyy
 * Date 2021/2/17 23:21
 **/
@Mapper
public interface AnnouncementMapper extends BaseMapper<Announcement> {

    @Select("select anno.id, anno.title, anno.create_person, e.name, anno.create_time, anno.level, anno.ifread, anno.status, anno.content\n" +
            "    from announcement anno join employee e on anno.create_person=e.id")
    @Results({
            @Result(column="create_person", property = "createPerson.id"),
            @Result(column="name", property = "createPerson.name"),
    })
    IPage<Announcement> selectForList(IPage<Announcement> page, @Param(Constants.WRAPPER) Wrapper<Announcement> queryWrapper);

    @Select("insert into emp_anno (emp_id, anno_id) values (#{e_id},#{anno_id})")
    void addHasRead(@Param("e_id") Long eid, @Param("anno_id") Long anno_id);
}
